﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL;

namespace DAL
{
    public class Article : IDAL.IArticle
    {
        DataMode.DataModeDataContext ctx = new DataMode.DataModeDataContext();

        public void addNewArticle(string article_name, string article_path, System.DateTime article_time)
        {
            DataMode.article narticle = new DataMode.article();
            narticle.article_name = article_name;
            narticle.article_path = article_path;
            narticle.article_time = article_time;
            ctx.article.InsertOnSubmit(narticle);
            ctx.SubmitChanges();
        }

        public void deleteArticle(int article_id)
        {
            var narticle = from pic in ctx.article
                          where pic.article_id == article_id
                          select pic;
            ctx.article.DeleteAllOnSubmit(narticle);
            ctx.SubmitChanges();
        }

        public void modifyArticle(int article_id, DateTime addDate, string discription)
        {
            
        }

        public IQueryable selectArticle(int article_id)
        {
            IQueryable<DataMode.article> narticle = from pic in ctx.article
                                           where pic.article_id == article_id
                                           select pic;
            return narticle;
        }
    }
}
